www.gusucode.com > 24Beta 虚拟主机版 1.0.0 Beta源码程序 > 24Beta 虚拟主机版 1.0.0 Beta源码程序/24Beta-1.0.0-vhost/library/global.php
<?php date_default_timezone_set('Asia/Shanghai'); /** * This is the shortcut to DIRECTORY_SEPARATOR */ defined('DS') or define('DS', DIRECTORY_SEPARATOR); /** * This is the shortcut to Yii::app() * @return CApplication */ function app() { return Yii::app(); } /** * This is the shortcut to Yii::app()->clientScript */ function cs() { return Yii::app()->clientScript; } /** * This is the shortcut to Yii::app()->createUrl() */ function url($route, $params=array(), $anchor = null, $ampersand='&') { return Yii::app()->createUrl($route, $params, $ampersand) . $anchor; } /** * This is the shortcut to Yii::app()->createAbsoluteUrl() */ function aurl($route, $params=array(), $schema='', $anchor = null, $ampersand='&') { return Yii::app()->createAbsoluteUrl($route, $params, $schema, $ampersand) . $anchor; } /** * This is the shortcut to CHtml::encode */ function h($text) { return htmlspecialchars($text, ENT_QUOTES, Yii::app()->charset); } /** * This is the shortcut to CHtml::link() */ function l($text, $url = '#', $htmlOptions = array()) { return CHtml::link($text, $url, $htmlOptions); } /** * This is the shortcut to Yii::t() with default category = 'stay' */ function t($message, $category = 'stay', $params = array(), $source = null, $language = null) { return Yii::t($category, $message, $params, $source, $language); } /** * This is the shortcut to Yii::app()->request->baseUrl * If the parameter is given, it will be returned and prefixed with the app baseUrl. */ function bu($url = null) { static $baseUrl; if ($baseUrl === null) $baseUrl = Yii::app()->request->baseUrl; return $url === null ? $baseUrl : $baseUrl. '/' . ltrim($url, '/'); } /** * This is the shortcut to Yii::app()->request->getBaseUrl(true) * If the parameter is given, it will be returned and prefixed with the app absolute baseUrl. */ function abu($url = null) { static $baseUrl; if ($baseUrl === null) $baseUrl = Yii::app()->request->getBaseUrl(true); return $url === null ? $baseUrl : $baseUrl. '/' . ltrim($url, '/'); } /** * Returns the named application parameter. * This is the shortcut to Yii::app()->params[$name]. */ function param($name) { return Yii::app()->params[$name]; } /** * This is the shortcut to Yii::app()->user. */ function user() { return Yii::app()->user; } /* * this is the shortcut to Yii::app()->theme->baseUrl */ function tbu($url = null) { static $themeBaseUrl; if ($themeBaseUrl === null) $themeBaseUrl = Yii::app()->theme->baseUrl; return $url === null ? $themeBaseUrl : $themeBaseUrl. '/' . ltrim($url, '/'); } /** * This is the shortcut to Yii::app()->authManager. */ function auth() { return Yii::app()->authManager; }